﻿using System;
using System.Web;
using System.Collections.Generic;
using BLToolkit.Mapping;
using BLToolkit.Data;
using BLToolkit.Reflection;

/// <summary>Id</summary>
public class Trip : LoggingObject
{
	public Trip()
	{
		route = new Route();
		bus = new Bus();
	}

	/// <summary>Id</summary>
	[Nullable]
	[MapField("Trip_id")]
	public Int64 Id { get; set; }

	/// <summary>Id правила, по которому сгенерирован рейс</summary>
	[Nullable]
	public Int64 TripRule_id { get; set; }

	/// <summary>Дата и время отправления рейса</summary>
	[Nullable]
	[MapField("Trip_DateTime")]
	public DateTime dateTime { get; set; }

	/// <summary>id автобуса</summary>
	[Nullable]
	public Int64 Bus_id { get { return bus.Id; } }
	/// <summary>автобус</summary>
	[Nullable]
	public Bus bus { get; set; }

	/// <summary>id маршрута</summary>
	[Nullable]
	public Int64 Route_id { get { return route.Id; } }
	/// <summary>маршрут</summary>
	[Nullable]
	public Route route { get; set; }


	public bool Merge()
	{
		try
		{
			SetLoggingInfo();
			this.Id = DBEntity<Trip>.Merge(this);
			return true;
		}
		catch { return false; }
	}
}
